package com.hq.bootdemo.service.impl;

import com.hq.bootdemo.entity.TypeEntity;
import com.hq.bootdemo.service.TypeService;
import org.springframework.data.convert.TypeMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class TypeServiceImpl implements TypeService {

    @Resource
    private TypeMapper typeMapper;

    @Override
    public List<TypeEntity> selectAll(String condition){
        return typeMapper.selectAll(condition);
    }
    @Override
    public boolean insertOne(TypeEntity typeEntity){
        if(typeEntity.getTName() == null || typeEntity.getTName() == "")return false;
        int row = typeMapper.selectOne(typeEntity);
        if(row != 0){
            return true;
        }
        return false;
    }

    @Override
    public boolean inserOne(Integer id) {
        return false;
    }

    @Override
    public  boolean delOne(Integer id){
        if (id == null || id == 0) return false;
        int row = typeMapper.delOne(id);
        return row !=0;
    }
    @Override
    public TypeEntity selectOne(Integer id){
        return  typeMapper.selectOne(id);
    }

}
